#include "viewer.h"
#include <GL/glut.h>

using namespace std;
using namespace qglviewer;
	
Viewer::Viewer(QWidget *parent)
	: QGLViewer(QGLFormat(QGL::SampleBuffers |
												QGL::DoubleBuffer |
												QGL::DepthBuffer |
												QGL::Rgba |
												QGL::AlphaChannel |
												QGL::StencilBuffer),parent)
	, _t(0.0f)
{
}
Viewer::~Viewer()
{
}
void Viewer::init()
{
	// Indicate the size of the scene
	setSceneRadius(2.0f);
	setSceneCenter(Vec(0.0f,0.0f,0.0f));
	// Try to restore previous state or focus the whole scene
	if (!restoreStateFromFile())
	{
		showEntireScene();
	}
}
void Viewer::animate()
{
	_t += animationPeriod()/1000.0f;
	if (_t>1) _t = 0.0f;
}
void Viewer::draw()
{
	static const Vec red  (1.0f,0.0f,0.0f);
	static const Vec green(0.0f,1.0f,0.0f);

	glColor3fv((1-_t)*red+_t*green);	
	glutSolidSphere(0.5f,30,30);
}
